package com.example.nonacademic_education.controller;

import cn.dev33.satoken.annotation.SaCheckRole;
import cn.dev33.satoken.annotation.SaIgnore;
import com.example.nonacademic_education.constant.Constant;
import com.example.nonacademic_education.data.request.LoginR;
import com.example.nonacademic_education.entity.Admin;
import com.example.nonacademic_education.entity.Student;
import com.example.nonacademic_education.service.impl.StudentServiceImpl;
import com.example.nonacademic_education.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Slf4j
@RestController
@RequestMapping("student_user")
public class StudentUserController {
    @Resource
    private StudentServiceImpl studentService;

    @GetMapping("getStudentByCardId")
    @SaCheckRole(Constant.STUDENT)
    public R getInformFormID(String identityCardId,Long studentId) {
        return studentService.getInformFormID(identityCardId,studentId);
    }
    @PostMapping("login")
    @SaIgnore
    public R login(@RequestBody LoginR admin, HttpServletRequest request) {
        return studentService.login(admin,request);
    }
    @PostMapping("uploadHeadImage")
    @SaCheckRole(Constant.STUDENT)
    public R uploadHeadImage(@RequestBody Student student) {
        return studentService.uploadHeadImage(student);
    }
    @PutMapping("resetPassword")
    @SaCheckRole(Constant.STUDENT)
    public R resetPassword(@RequestBody Student student) {
        return studentService.resetPassword(student);
    }
    @PostMapping("uploadIdentificationPhoto")
    @SaCheckRole(Constant.STUDENT)
    public R uploadIdentificationPhoto(@RequestParam("file") MultipartFile file) {
        return studentService.uploadIdentificationPhoto(file);
    }
}
